import rclpy
from rclpy.node import Node
from std_msgs.msg import String
import time
import qrcode

def call(massage):
    link=massage.data
    print(link)
    qr=qrcode.QRCode(
        version=3,
        error_correction=qrcode.constants.ERROR_CORRECT_Q,
        box_size=10,
        border=4,
    )
    qr.add_data(link)
    qr.make(fit=True)
    img=qr.make_image(fill_color="black",background_color="write")
    name=massage.data+".png"
    img.save(name)
def main (args=None):

    rclpy.init(args=args)#初始化rclpy
    node=Node("speak")#新建一个节点
    # node.pub_novel=node.create_publisher(String,'image_raw',10)
    node.get_logger().info("功能启动!!!")

    node.sub_novel=node.create_subscription(String,"QR_Code_Content",call,10)


    rclpy.spin(node)#保持节点运行 检测是否收到退出指令  （Ctrl+c）
    rclpy.shutdown()#关闭rclpy